<div class="input_form">

<?php
	echo form_open('bur/detail_payment_plan/process_add');
?>

<table class="table" style="width:auto">
<tr><td class="th">Nama</td><td valign="top"><?=$nama?></td><td class="spacer"></td><td class="th">NIM</td><td valign="top"><?=$nim?></td></tr>
<tr><td class="th">Program Studi</td><td valign="top"><?=$prodi?></td><td class="spacer"></td><td class="th">Angkatan</td><td valign="top"><?=$angkatan?></td></tr>
<tr><td class="th">Bulan</td><td valign="top"><?=$bulan?></td><td class="spacer"></td><td class="th">Semester</td><td valign="top"><?=$semester_desc?></td></tr>
</table>

<div>
<table class="table" style="width:auto">
<thead><tr>
<th>No</th><th>Jenis Biaya</th><th>Utang</th><th>Denda</th><th>Kewajiban Baru</th><th>Minimal Bayar</th><th>Jumlah Bayar</th><th>Keterangan</th></tr></thead><tbody>
<?php
	$no = 1;

	function _format($number)
	{
		if (is_numeric($number))
			return number_format($number, 2, ',', '.');
	}
	
	foreach ($tabel as $idx => $row) {
?>
<tr>
	<td valign="top"><?=$no?></td>
	<td valign="top"><?=$row['biaya']?><input type="hidden" name="biaya_<?=$no?>" value="<?=$row['biaya']?>"><input type="hidden" name="key_biaya_<?=$no?>" value="<?=$row['key_biaya']?>"></td>
	<td valign="top" align="right"><?=_format($row['tunggakan'])?></td>
	<td valign="top" align="right"><?=_format($row['denda'])?></td>	
	<td valign="top" align="right"><?=_format($row['kewajiban'])?></td>
	<td valign="top" align="right"><?=_format($row['minimal'])?></td>	
	<td valign="top"><input type="text" name="rp_<?=$no?>" value="<?=$row['rp']?>" style="text-align:right" onkeyup="recalculate_total(); strip_nonnumeric(this)" <?php if ($readonly) echo 'readonly="readonly" ' ?>/></td>
	<td valign="top"><input type="text" name="keterangan_<?=$no?>" value="<?=$row['keterangan']?>" <?php if ($readonly) echo 'readonly="readonly" ' ?>/></td>
</tr>
<?php
		$no++;
	}
?>
<tr>
	<td valign="top"></td>
	<td valign="top" style="text-align:right"><strong>Jumlah</strong></td>
	<td valign="top" align="right"><?=_format($total_tunggakan)?></td>
	<td valign="top" align="right"><?=_format($total_denda)?></td>	
	<td valign="top" align="right"><?=_format($total_kewajiban)?></td>
	<td valign="top" align="right"><?=_format($total_minimal)?></td>
	<td valign="top" align="right"><span id="jumlah"></span></td>
	<td valign="top"><input type="hidden" name="nim" value="<?=$nim?>" /><input type="hidden" name="semester" value="<?=$semester?>" /><input type="hidden" name="bulan" value="<?=$bulan?>" /><input type="hidden" name="__referrer" value="<?=$referrer?>" /></td>
</tr>
<?php if (!$readonly) {
?>
<tr>
<td colspan="8" valign="top" align="center"><input type="submit" name="__submit" value="Submit"  /></td></tr>
<?php
	}
?>
</tbody></table>


</div>

<?php
	echo form_close();
?>
</div>
<br />
<p>
<strong>Catatan:</strong> Jumlah saldo kewajiban awal, kewajiban baru, dan pembayaran minimal di atas merupakan data salinan dari arsip bagian keuangan. Apabila pada suatu saat ditemukan perbedaan antara jumlah yang tertera pada halaman ini dengan arsip bagian keuangan, arsip bagian keuangan dianggap sebagai data yang benar, dan akan dilakukan tindakan koreksi seperlunya.
</p>

<script type="text/javascript">
	function strip_nonnumeric(that) {
		that.value = that.value.replace(/[^0-9]/g, '');
	}
	function recalculate_total() {
		var elements = document.forms[0].elements;
		
		document.getElementById('jumlah').innerHTML = 0.00;
		
		var i;
		var name;
		var value;

		var total = 0.00;
		
		for (i=0; i<elements.length; i++) {
			
			if (elements[i].name.indexOf('rp')==0) {			
				value = parseFloat(elements[i].value);
				if (isNaN(value)) {
					value = 0.00;
				}
				
				total = total + value;
			}
		}
		document.getElementById('jumlah').innerHTML = indoCurrencyFormatted(total);
		
	}
	recalculate_total();
</script>